<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="主表格id" prop="excelId">
        <el-input v-model="queryParams.excelId" placeholder="请输入主表格id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="试验次数" prop="shiycs">
        <el-input v-model="queryParams.shiycs" placeholder="请输入试验次数" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒容积" prop="tongrj">
        <el-input v-model="queryParams.tongrj" placeholder="请输入筒容积" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒质量" prop="tongzl">
        <el-input v-model="queryParams.tongzl" placeholder="请输入筒质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒加湿土质量" prop="tongjstzl">
        <el-input v-model="queryParams.tongjstzl" placeholder="请输入筒加湿土质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="湿土质量" prop="shitzl">
        <el-input v-model="queryParams.shitzl" placeholder="请输入湿土质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="湿密度" prop="shimd">
        <el-input v-model="queryParams.shimd" placeholder="请输入湿密度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="干密度" prop="ganmd">
        <el-input v-model="queryParams.ganmd" placeholder="请输入干密度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒号1" prop="heh1">
        <el-input v-model="queryParams.heh1" placeholder="请输入盒号1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒质量1" prop="hezl1">
        <el-input v-model="queryParams.hezl1" placeholder="请输入盒质量1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒+湿土质量1" prop="hejstzl1">
        <el-input v-model="queryParams.hejstzl1" placeholder="请输入盒+湿土质量1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒+干土质量1" prop="hejgtzl1">
        <el-input v-model="queryParams.hejgtzl1" placeholder="请输入盒+干土质量1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="水分质量1" prop="shuifzl1">
        <el-input v-model="queryParams.shuifzl1" placeholder="请输入水分质量1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="干土质量1" prop="gantzl1">
        <el-input v-model="queryParams.gantzl1" placeholder="请输入干土质量1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="含水率1" prop="hansl1">
        <el-input v-model="queryParams.hansl1" placeholder="请输入含水率1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒号2" prop="heh2">
        <el-input v-model="queryParams.heh2" placeholder="请输入盒号2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒质量2" prop="hezl2">
        <el-input v-model="queryParams.hezl2" placeholder="请输入盒质量2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒+湿土质量2" prop="hejstzl2">
        <el-input v-model="queryParams.hejstzl2" placeholder="请输入盒+湿土质量2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒+干土质量2" prop="hejgtzl2">
        <el-input v-model="queryParams.hejgtzl2" placeholder="请输入盒+干土质量2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="水分质量2" prop="shuifzl2">
        <el-input v-model="queryParams.shuifzl2" placeholder="请输入水分质量2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="干土质量2" prop="gantzl2">
        <el-input v-model="queryParams.gantzl2" placeholder="请输入干土质量2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="含水率2" prop="hansl2">
        <el-input v-model="queryParams.hansl2" placeholder="请输入含水率2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="平均含水率" prop="hanslpjz">
        <el-input v-model="queryParams.hanslpjz" placeholder="请输入平均含水率" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb5 top-right-btn small-line-height">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['report_tg:tgTdjsjlbBaDetail:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['report_tg:tgTdjsjlbBaDetail:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['report_tg:tgTdjsjlbBaDetail:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['report_tg:tgTdjsjlbBaDetail:export']">导出</el-button>
      </el-col>
      <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
    </el-row>

    <el-table border stripe v-loading="loading" :data="tgTdjsjlbBaDetailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" v-if="true" />
      <el-table-column label="主表格id" align="center" prop="excelId" />
      <el-table-column label="试验次数" align="center" prop="shiycs" />
      <el-table-column label="筒容积" align="center" prop="tongrj" />
      <el-table-column label="筒质量" align="center" prop="tongzl" />
      <el-table-column label="筒加湿土质量" align="center" prop="tongjstzl" />
      <el-table-column label="湿土质量" align="center" prop="shitzl" />
      <el-table-column label="湿密度" align="center" prop="shimd" />
      <el-table-column label="干密度" align="center" prop="ganmd" />
      <el-table-column label="盒号1" align="center" prop="heh1" />
      <el-table-column label="盒质量1" align="center" prop="hezl1" />
      <el-table-column label="盒+湿土质量1" align="center" prop="hejstzl1" />
      <el-table-column label="盒+干土质量1" align="center" prop="hejgtzl1" />
      <el-table-column label="水分质量1" align="center" prop="shuifzl1" />
      <el-table-column label="干土质量1" align="center" prop="gantzl1" />
      <el-table-column label="含水率1" align="center" prop="hansl1" />
      <el-table-column label="盒号2" align="center" prop="heh2" />
      <el-table-column label="盒质量2" align="center" prop="hezl2" />
      <el-table-column label="盒+湿土质量2" align="center" prop="hejstzl2" />
      <el-table-column label="盒+干土质量2" align="center" prop="hejgtzl2" />
      <el-table-column label="水分质量2" align="center" prop="shuifzl2" />
      <el-table-column label="干土质量2" align="center" prop="gantzl2" />
      <el-table-column label="含水率2" align="center" prop="hansl2" />
      <el-table-column label="平均含水率" align="center" prop="hanslpjz" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['report_tg:tgTdjsjlbBaDetail:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['report_tg:tgTdjsjlbBaDetail:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改土的击实记录 详细对话框 -->
    <jy-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主表格id" prop="excelId">
          <el-input v-model="form.excelId" placeholder="请输入主表格id" />
        </el-form-item>
        <el-form-item label="试验次数" prop="shiycs">
          <el-input v-model="form.shiycs" placeholder="请输入试验次数" />
        </el-form-item>
        <el-form-item label="筒容积" prop="tongrj">
          <el-input v-model="form.tongrj" placeholder="请输入筒容积" />
        </el-form-item>
        <el-form-item label="筒质量" prop="tongzl">
          <el-input v-model="form.tongzl" placeholder="请输入筒质量" />
        </el-form-item>
        <el-form-item label="筒加湿土质量" prop="tongjstzl">
          <el-input v-model="form.tongjstzl" placeholder="请输入筒加湿土质量" />
        </el-form-item>
        <el-form-item label="湿土质量" prop="shitzl">
          <el-input v-model="form.shitzl" placeholder="请输入湿土质量" />
        </el-form-item>
        <el-form-item label="湿密度" prop="shimd">
          <el-input v-model="form.shimd" placeholder="请输入湿密度" />
        </el-form-item>
        <el-form-item label="干密度" prop="ganmd">
          <el-input v-model="form.ganmd" placeholder="请输入干密度" />
        </el-form-item>
        <el-form-item label="盒号1" prop="heh1">
          <el-input v-model="form.heh1" placeholder="请输入盒号1" />
        </el-form-item>
        <el-form-item label="盒质量1" prop="hezl1">
          <el-input v-model="form.hezl1" placeholder="请输入盒质量1" />
        </el-form-item>
        <el-form-item label="盒+湿土质量1" prop="hejstzl1">
          <el-input v-model="form.hejstzl1" placeholder="请输入盒+湿土质量1" />
        </el-form-item>
        <el-form-item label="盒+干土质量1" prop="hejgtzl1">
          <el-input v-model="form.hejgtzl1" placeholder="请输入盒+干土质量1" />
        </el-form-item>
        <el-form-item label="水分质量1" prop="shuifzl1">
          <el-input v-model="form.shuifzl1" placeholder="请输入水分质量1" />
        </el-form-item>
        <el-form-item label="干土质量1" prop="gantzl1">
          <el-input v-model="form.gantzl1" placeholder="请输入干土质量1" />
        </el-form-item>
        <el-form-item label="含水率1" prop="hansl1">
          <el-input v-model="form.hansl1" placeholder="请输入含水率1" />
        </el-form-item>
        <el-form-item label="盒号2" prop="heh2">
          <el-input v-model="form.heh2" placeholder="请输入盒号2" />
        </el-form-item>
        <el-form-item label="盒质量2" prop="hezl2">
          <el-input v-model="form.hezl2" placeholder="请输入盒质量2" />
        </el-form-item>
        <el-form-item label="盒+湿土质量2" prop="hejstzl2">
          <el-input v-model="form.hejstzl2" placeholder="请输入盒+湿土质量2" />
        </el-form-item>
        <el-form-item label="盒+干土质量2" prop="hejgtzl2">
          <el-input v-model="form.hejgtzl2" placeholder="请输入盒+干土质量2" />
        </el-form-item>
        <el-form-item label="水分质量2" prop="shuifzl2">
          <el-input v-model="form.shuifzl2" placeholder="请输入水分质量2" />
        </el-form-item>
        <el-form-item label="干土质量2" prop="gantzl2">
          <el-input v-model="form.gantzl2" placeholder="请输入干土质量2" />
        </el-form-item>
        <el-form-item label="含水率2" prop="hansl2">
          <el-input v-model="form.hansl2" placeholder="请输入含水率2" />
        </el-form-item>
        <el-form-item label="平均含水率" prop="hanslpjz">
          <el-input v-model="form.hanslpjz" placeholder="请输入平均含水率" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button size="small" @click="cancel">取 消</el-button>
      </div>
    </jy-dialog>
  </div>
</template>

<script>
import { listTgTdjsjlbBaDetail, getTgTdjsjlbBaDetail, delTgTdjsjlbBaDetail, addTgTdjsjlbBaDetail, updateTgTdjsjlbBaDetail } from "@/api/report_tg/tgTdjsjlbBaDetail";

export default {
  name: "TgTdjsjlbBaDetail",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 土的击实记录 详细表格数据
      tgTdjsjlbBaDetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        excelId: undefined,
        shiycs: undefined,
        tongrj: undefined,
        tongzl: undefined,
        tongjstzl: undefined,
        shitzl: undefined,
        shimd: undefined,
        ganmd: undefined,
        heh1: undefined,
        hezl1: undefined,
        hejstzl1: undefined,
        hejgtzl1: undefined,
        shuifzl1: undefined,
        gantzl1: undefined,
        hansl1: undefined,
        heh2: undefined,
        hezl2: undefined,
        hejstzl2: undefined,
        hejgtzl2: undefined,
        shuifzl2: undefined,
        gantzl2: undefined,
        hansl2: undefined,
        hanslpjz: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [{ required: true, message: "id不能为空", trigger: "blur" }],
        excelId: [{ required: true, message: "主表格id不能为空", trigger: "blur" }],
        shiycs: [{ required: true, message: "试验次数不能为空", trigger: "blur" }],
        tongrj: [{ required: true, message: "筒容积不能为空", trigger: "blur" }],
        tongzl: [{ required: true, message: "筒质量不能为空", trigger: "blur" }],
        tongjstzl: [{ required: true, message: "筒加湿土质量不能为空", trigger: "blur" }],
        shitzl: [{ required: true, message: "湿土质量不能为空", trigger: "blur" }],
        shimd: [{ required: true, message: "湿密度不能为空", trigger: "blur" }],
        ganmd: [{ required: true, message: "干密度不能为空", trigger: "blur" }],
        heh1: [{ required: true, message: "盒号1不能为空", trigger: "blur" }],
        hezl1: [{ required: true, message: "盒质量1不能为空", trigger: "blur" }],
        hejstzl1: [{ required: true, message: "盒+湿土质量1不能为空", trigger: "blur" }],
        hejgtzl1: [{ required: true, message: "盒+干土质量1不能为空", trigger: "blur" }],
        shuifzl1: [{ required: true, message: "水分质量1不能为空", trigger: "blur" }],
        gantzl1: [{ required: true, message: "干土质量1不能为空", trigger: "blur" }],
        hansl1: [{ required: true, message: "含水率1不能为空", trigger: "blur" }],
        heh2: [{ required: true, message: "盒号2不能为空", trigger: "blur" }],
        hezl2: [{ required: true, message: "盒质量2不能为空", trigger: "blur" }],
        hejstzl2: [{ required: true, message: "盒+湿土质量2不能为空", trigger: "blur" }],
        hejgtzl2: [{ required: true, message: "盒+干土质量2不能为空", trigger: "blur" }],
        shuifzl2: [{ required: true, message: "水分质量2不能为空", trigger: "blur" }],
        gantzl2: [{ required: true, message: "干土质量2不能为空", trigger: "blur" }],
        hansl2: [{ required: true, message: "含水率2不能为空", trigger: "blur" }],
        hanslpjz: [{ required: true, message: "平均含水率不能为空", trigger: "blur" }]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询土的击实记录 详细列表 */
    getList() {
      this.loading = true;
      listTgTdjsjlbBaDetail(this.queryParams).then((response) => {
        this.tgTdjsjlbBaDetailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        excelId: undefined,
        shiycs: undefined,
        tongrj: undefined,
        tongzl: undefined,
        tongjstzl: undefined,
        shitzl: undefined,
        shimd: undefined,
        ganmd: undefined,
        heh1: undefined,
        hezl1: undefined,
        hejstzl1: undefined,
        hejgtzl1: undefined,
        shuifzl1: undefined,
        gantzl1: undefined,
        hansl1: undefined,
        heh2: undefined,
        hezl2: undefined,
        hejstzl2: undefined,
        hejgtzl2: undefined,
        shuifzl2: undefined,
        gantzl2: undefined,
        hansl2: undefined,
        hanslpjz: undefined,
        delFlag: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加土的击实记录 详细";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids;
      getTgTdjsjlbBaDetail(id).then((response) => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改土的击实记录 详细";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateTgTdjsjlbBaDetail(this.form)
              .then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              })
              .finally(() => {
                this.buttonLoading = false;
              });
          } else {
            addTgTdjsjlbBaDetail(this.form)
              .then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              })
              .finally(() => {
                this.buttonLoading = false;
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除土的击实记录 详细编号为"' + ids + '"的数据项？')
        .then(() => {
          this.loading = true;
          return delTgTdjsjlbBaDetail(ids);
        })
        .then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {})
        .finally(() => {
          this.loading = false;
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "report_tg/tgTdjsjlbBaDetail/export",
        {
          ...this.queryParams
        },
        `tgTdjsjlbBaDetail_${new Date().getTime()}.xlsx`
      );
    }
  }
};
</script>
